package com.bbt.dormassistant.controller;

import com.bbt.dormassistant.util.RedisUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Api(tags = "Redis测试接口")
@RestController
@RequestMapping("/hello")
public class HelloController {


    @Autowired
    private RedisUtil redisUtil;

    @GetMapping("/hello")
    public Map hello(@RequestParam(value = "key")String key){
        Map<String, Object> map = new HashMap<>();
        map.put("value",redisUtil.get(key));
        return map;
    }

    @PostMapping("world")
    public Map world(@RequestParam(value = "key") String key,
                     @RequestParam(value = "value") String value){
        Map<String, Object> map = new HashMap<>();
        map.put("success",redisUtil.set(key,value));
        return map;
    }

}
